<template>
	<view class="u-page">
		<view class="header">
		
		</view>
		
		<view class="content" >
			<view class="projecttitle">{{title}}</view>
			<view v-for="(item,key) in list" :key="key">
				<view class="projectUser">
					<image src="../../../static/icon/user.png" mode=""></image>
					<text>{{item.stockType}}</text>
					<text class="name">{{item.name}}</text>
				</view>
				<view v-if="level == '1'">
					<view class="total">
						<view>总认缴：{{item.totalShouldCapi}}</view>
						<view>总实缴：{{item.totalRealCapi}}</view>
					</view>
					<view class="projectFile" v-for="(total,k) in item.shouldCapiItems" :key="k">
						<view>出资时间：{{total.date}}</view>
						<view>认缴出资额：{{total.capi}}</view>
						<view>出资方式：{{total.type}}</view>
					</view>
				</view>
				<view v-else>
					<view class="total">
						<view>暂无权限查看</view>
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pid:'',
				userData:{},
				title:'',
				level:"0",
				type:1,
				strings: '',
				list:[]
			}
			
		},
		onLoad(option) {
			this.pid=option.id
			this.title = option.title
			
			let user = uni.getStorageSync('userData');
			this.userData = user;
			
			this.project(option.id)
		},
		methods: {
			async project(pid){
				const project = await this.GQL({
					"operationName": "allSlProjectShareholders",
					"query": "query allSlProjectShareholders($filter: SlProjectShareholderFilter) { allSlProjectShareholders(filter:$filter) { nodes { capi date name pid sid stockType totalShouldCapi totalRealCapi shouldCapiItems realCapiItems type createtime} } }",
					"variables": {"filter": {"pid": {"equalTo": pid}}}
				})
				//获取用户
				const userData = await this.GQL({
					"operationName": "allSlUserProjectvips",
					"query": "query allSlUserProjectvips($filter: SlUserProjectvipFilter) { allSlUserProjectvips(filter:$filter) { nodes { vid uid pid level } } }",
					"variables": {"filter": {"uid": {"equalTo": this.userData.uid}}}
				})
							
				if(userData.data.allSlUserProjectvips.nodes !=''){
					this.level = '1'
				}else{
					this.level = '0'
				}
				// console.log('----',project)
				if(project.data.allSlProjectShareholders.nodes !=''){
					project.data.allSlProjectShareholders.nodes.forEach(function (item, index) {
						if(item.shouldCapiItems){
							item.shouldCapiItems = JSON.parse(item.shouldCapiItems)
						}
					});
					this.list = project.data.allSlProjectShareholders.nodes
				}else{
					//请求API
					this.getApiList()
				}
			},
			getApiList(){
				let that = this
				uni.request({
					url:that.HttpServe+"/Api/Partners",
					method:"POST",
					data:{
						pid:that.pid
					},
					success(res) {
						console.log('res',res)
						if(res.data.code == 200){
							let list1 = res.data
							that.list = list1.data.result.items
						}else{
							uni.showToast({ title: '获取信息失败', icon: 'error', duration: 3000 });
							uni.navigateBack({
								delta: 1
							})
						}
						
					}
				})
			},
			goback(){
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style lang="scss">
	.u-page{
		background-color: #FBFCFE;
	}
	 .header{
	 	width: 100%;
	 	height: 260px;
	 	/* color: #FFFFFF; */
		background: linear-gradient(#C7171E, #f0f2f5); /* 标准的语法 */
	 	
	 }
	 .content{
		 position: relative;
		 margin: 30rpx;
		 padding: 30rpx;
		 background-color: #FFFFFF;
		 min-height: 100vh;
		 border-radius: 10px;
		 // top: -190px;
		 top: -260px;
		 .projecttitle{
			 font-size: 16px;
			 color: #161E3E;
			 font-weight: 500;
			 // padding: 10px;
		 }
		 .projectTag{
			 margin: 5px 15px 0px 15px;
			 .tag{
				 margin-left: 5px;
			 }
		 }
		 .projectcontent{
			 margin: 15px;
			 
		 }
		 
		 .projectUser{
			 margin: 20rpx 0;
			 font-size: 28rpx;
			 font-family: PingFangSC-Regular, PingFang SC;
			 font-weight: 400;
			 color: #161E3E;
			 line-height: 64rpx;
			 image{
				 width: 26rpx;
				 height:26rpx;
				 padding-right: 5px;
				 vertical-align: middle;
				 line-height: 26rpx;
			 }
			 .name{
				margin-left: 10px;
				font-weight: 400;
				color: #767B8D;
				line-height: 26rpx;
				font-size: 30rpx;
			 }
			
		 }
		 .CarId{
			 padding: 10px 0px 20px 0px;
			 font-size: 15px;
			 color: #007AFE;
		 }
		 .ID{
			 font-size: 15px;
			 color: #838898;
		 }
		 .projectId{
			 margin: 20px 10px 20px 10px;
			 border-bottom: 1px solid #D8D8D8;
		 }
		 .projectAddress{
			  margin: 20px 10px 20px 10px;
		 }
		 .total{
			 margin: 0 10px;
			 font-size: 14px;
			 font-family: PingFangSC-Regular, PingFang SC;
			 font-weight: 400;
			 color: #767B8D;
			 line-height: 20px;
			 view{
				 margin-bottom: 10px;
			 }
		 }
		 .projectFile{
			  margin: 0 10px;
			  font-size: 15px;
			 font-family: PingFangSC-Regular, PingFang SC;
			 font-weight: 400;
			 color: #767B8D;
			 line-height: 20px;
			 view{
			 				 margin-bottom: 10px;
			 }
		 }
	 }

</style>
